package com.gjy.liteflow.util;

import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-08-14 09:23:57
 */
@Component
public class EnvironmentUtil implements EnvironmentAware {

    private static Environment environment;

    @Override
    public void setEnvironment(Environment environment) {
        EnvironmentUtil.environment = environment;
    }

    public static String getProperty(String key) {
        if (StringUtils.hasText(key)) {
            return environment.getProperty(key);
        }
        return null;
    }
}
